﻿@model Alma.Models.CartModel

@{
    ViewContext.Controller.ViewBag.Breadcrumb.Enter("Mon panier");
}
<div class="fullcol">
<div class="boxes">
<h1>Ma liste de courses</h1>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>


@if (Model.productList.Count == 0)
{
    <p>Aucun produit dans le panier.</p>
}
else
{
    <table>
    <tr><th></th><th>Nom</th><th>Quantité</th><th>Magasin</th><th></th><th></th></tr>
    @foreach (var se in Model.productList)
    {
        <tr>
        <td><img alt="Product Illustration" src="@Url.Content(se.ImgUrl)" /></td>
        <td>@Html.ActionLink(se.Name, "Show", "Product", new { id = se.ID }, null)</td>
        <td>@Html.ActionLink("-", "Less", "Cart", new { id = se.ID }, null)@se.Quantity@Html.ActionLink("+", "More", "Cart", new { id = se.ID }, null)</td>
        <td>@Html.ActionLink(se.Name_Shop, "Show", "Shop", new { id = se.ID_Shop }, null)</td>
        <td>@Html.ActionLink("Retirer", "Delete", "Cart", new { id = se.ID }, null)</td>
        <td>@foreach (var list in Model.publicLists)
        {
            <br />@Html.ActionLink("Ajouter à "+list.List_Name+" ", "AddProduct", "List", new { idList = list.ID, idProduct = se.ID }, null)
        }
        </td>
        </tr>
    }
    </table>
    @Html.ActionLink("Vider mon panier", "Free", "Cart")<br />
    
    <script type="text/javascript">

        function printPopUp() {
            window.open("@Url.Action("Print", "Cart")", "Liste de courses",
                "status = 1, height = 600, width = 400, resizable = 0");
        }

    </script>
    <a href="javascript:printPopUp()">Imprimer</a>
    foreach (var list in Model.publicLists)
    {
            <br />@Html.ActionLink("Copier le panier dans " + list.List_Name + " ", "CartToList", "List", new { idList = list.ID, idUser = Session["UserId"] }, null)
    }
}
<br /><br /><h1>Mes listes publiques</h1>
@if (Model.publicLists.Count == 0)
{
    <p>Aucun produit dans le panier.</p>
}
else
{
 <table>
    <tr><th></th><th>Nom</th><th>Produits</th></tr>
  @foreach (var se in Model.publicLists)
  {
        <tr>
        <td>@Html.ActionLink("Voir", "Show", "List", new { id = se.ID }, null) | @Html.ActionLink("Vider", "Free", "List", new { idList = se.ID }, null) | @Html.ActionLink("Supprimer", "Delete", "List", new { id = se.ID }, null)</td>
        <td>@se.List_Name</td>
        <td>@se.productList.Count</td>
        </tr>
  }
    </table>
}
@Html.ActionLink("Nouvelle liste", "Create", "List", new { id = Session["UserId"] }, null)
</div>
</div>
